{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Newton's method in 1D"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 28,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import numpy as np\n",
        "import matplotlib.pyplot as pt"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Here's a function:"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 29,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "a = 17.09\n",
        "b = 9.79\n",
        "c = 0.6317\n",
        "d = 0.9324\n",
        "e = 0.4565\n",
        "\n",
        "def f(x):\n",
        "    return a*x**4 + b*x**3 + c*x**2 + d*x + e\n",
        "\n",
        "def df(x):\n",
        "    return 4*a*x**3 + 3*b*x**2 + 2*c*x + d\n",
        "\n",
        "def d2f(x):\n",
        "    return 3*4*a*x**2 + 2*3*b*x + 2*c"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Let's plot the thing:"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 30,
      "metadata": {
        "collapsed": false
      },
      "outputs": [
        {
          "data": {
            "text/plain": [
              "[<matplotlib.lines.Line2D at 0x7f3774d78cf8>]"
            ]
          },
          "execution_count": 30,
          "metadata": {},
          "output_type": "execute_result"
        },
        {
          "data": {
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX8AAAEACAYAAABbMHZzAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XmYVNW57/Hvy+BsRFFBBUNAMA6JgAgERAtHxIh61DgP\nUa84RWPuzVFzjLae41FzMpBEIz4qiUSjIk6oqChSihNRGUQEBQUFhMYB8BBBgX7vH6vQtummi95V\ntap6/z7PUw9VXatr/2iot1etvdba5u6IiEi6tIgdQERESk/FX0QkhVT8RURSSMVfRCSFVPxFRFJI\nxV9EJIUSFX8z28zMJpnZVDN728xuaKDdn8xstplN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2C43FPm6mZ3e\n2IsWaqrneiplgdgGcv7Ht8K4e31rEcysC/Bzwkey5cADZnaqu99TTjkJ/9Y9gYvd/TUzGwZcAVxd\nTjnN7McWEQ9NAAACWElEQVTAEnefYmaZQmarc5ykP891r7MVoVd4ae4TQLHl+76o+4mp1EUr7+OZ\n2UDgbKB/8eLUK5+Mw4Arcv8PjDifRPPJ2Zrw/j6YMPrwipm96u6zG/qGohV/dz804UssBDrWetyR\n8BuvoDaU08yqzay9uy82s52AJfU06wW87O6f5r7nIaAfYby6nHIuABa4+2u5x6MJxb+gCpCzHzDE\nzAYDmwHfMbOR7n5GmeXEzFoDDwJ3u/sjhcy3Afm8L+q26UDphyLzev/mTvLeDgxy96UlyrZOPhn3\nBe4LdZ/tgSPMbLW7jylNRCC/nPOBT9x9JbDSzF4A9gEaLP7lMOzT6AIxM9uEsECslD9wcsc7M3f/\nTKC+N/gsoK+ZbZ7rGRxCWNNQSo3mdPfFwHwz65b70iGEE0SllE/OX7l7R3f/HnAS8FyhC38eGs2Z\n+7e+E3jb3YeVMFs+74sxwBm5nH0JQ5HVlFajOc1sV+Ah4DR3n1PifHlldPfO7v693P/H0cAFJS78\neeUEHgX2z82S24Jwon/DdajUZ65zZ6KPJfymWgksBp7MfX1n4Ila7Y4gzKKYA1wZIed2wLPAu8A4\noE0DOf+dUEinE060tS7TnPsArwHTCG+6Us/2yStnrfYHEme2T6M5gf0J5ySmAlNyt0Elyrfe+wIY\nCgyt1ebm3PPTaGBGXeychBP6n9b6+f2z3DLWaftX4N/K8WeZe/z/atWhSxp7TS3yEhFJoXIY9hER\nkRJT8RcRSSEVfxGRFFLxFxFJIRV/EZEUUvEXEUkhFX8RkRRS8RcRSaH/D3ABGsB/cUObAAAAAElF\nTkSuQmCC\n",
            "text/plain": [
              "<matplotlib.figure.Figure at 0x7f3774f22080>"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        }
      ],
      "source": [
        "xmesh = np.linspace(-1, 0.5\n",
        "                    , 100)\n",
        "pt.ylim([-1, 3])\n",
        "pt.plot(xmesh, f(xmesh))"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Let's fix an initial guess:"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 31,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "x = 0.3"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 32,
      "metadata": {
        "collapsed": false
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "0.14466962664624314\n"
          ]
        },
        {
          "data": {
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX8AAAEACAYAAABbMHZzAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XecVNX5x/HPwy5NRYr0ogjS6wLCSgkD0lwFIUIQFfhZ\nIioimt8vUZKYoLHEaIIdUTSKIggoHRQFRkEEQYoKLEVYBQSULqGzz++PO5h12TLslDOz87xfr3k5\n5ey9X5edZ86ce+65oqoYY4xJLEVcBzDGGBN9VvyNMSYBWfE3xpgEZMXfGGMSkBV/Y4xJQFb8jTEm\nAYVU/EWkhIgsE5HVIrJORB7Ppd2zIrJJRNaISEoo+zTGGBO65FB+WFWPiUgnVT0iIsnAYhFpr6qL\nz7QRkTTgMlWtIyJtgNFAamixjTHGhCLkYR9VPRK4WwxIAvZla9ILeCPQdhlQRkQqhbpfY4wxBRdy\n8ReRIiKyGtgNLFTVddmaVAO2ZXm8Hage6n6NMcYUXDh6/pmq2hyvoP9KRHw5NJPsPxbqfo0xxhRc\nSGP+WanqQRGZDbQC/Fle2gHUyPK4euC5XxAR+0AwxpgCUNXsHex8hTrbp7yIlAncLwl0BVZlazYD\nGBRokwocUNXdOW1PVZ3cOnRQ5s8Pru1f//pXZzmDvcVDxnjJOeqzUaRcn+I8R2H5fSZCzowMpWJF\nJTNT2bR3E1WeqkJmZmbEchZUqMM+VYAFgTH/ZcBMVZ0vIkNEZEigoM8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AAASUVORK5CYII=\n",
            "text/plain": [
              "<matplotlib.figure.Figure at 0x7f37751a22b0>"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        }
      ],
      "source": [
        "dfx = df(x)\n",
        "d2fx = d2f(x)\n",
        "\n",
        "# carry out the Newton step\n",
        "xnew = x - dfx / d2fx\n",
        "\n",
        "# plot approximate function\n",
        "pt.plot(xmesh, f(xmesh))\n",
        "pt.plot(xmesh, f(x) + dfx*(xmesh-x) + d2fx*(xmesh-x)**2/2)\n",
        "pt.plot(x, f(x), \"o\", color=\"red\")\n",
        "pt.plot(xnew, f(xnew), \"o\", color=\"green\")\n",
        "pt.ylim([-1, 3])\n",
        "\n",
        "# update\n",
        "x = xnew\n",
        "print(x)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "* What convergence order does this method achieve?"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 33,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "# Quadratic, because it's just like doing 'equation-solving Newton' on f'."
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.5.1+"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}